<%@page import="java.util.Collection"%>
<%@page import="avicit.platform6.api.syslookup.dto.SysLookupSimpleVo"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Map"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sec" uri="/WEB-INF/tags/shiro.tld"%>
<%@ page import="avicit.platform6.commons.utils.ComUtil"%>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>编辑</title>

<base href="<%=ComUtil.getRequestPath(request) %>">
<jsp:include
	page="/avicit/platform6/component/common/EasyUIJsInclude.jsp"></jsp:include>
<jsp:include page="/avicit/im/common/ImUIJSCSSInclude.jsp"></jsp:include>
<link href="avicit/cape/oms/css/icon.css" type="text/css"
	rel="stylesheet">
</head>
<body class="easyui-layout" fit="true">
	<% Map<String, Object> map = (Map<String, Object>)request.getAttribute("cbbFondsServerV"); %>
	<div region="center" border="false" style="overflow: hidden;">
		<form id="formCbbFondsService" method="post">
			<table class="form_commonTable">
				<tr>
					<sec:accesscontrollist hasPermission="3"
						domainObject="formdialog_CbbFondsServiceAdd_formCbbFondsService_odCode">
						<th width="20%"><span class=""></span>全宗号：</th>
						<td width="30%" class="input-readonly"><input type="text" validType="length[0,100]"
							style="" class="easyui-validatebox"
							data-options="required:true" title="全宗号" id="odCode"
							value="<%=map.get("ORG_CODE") %>" readonly="readonly" /></td>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3"
						domainObject="formdialog_CbbFondsServiceAdd_formCbbFondsService_odName">
						<th width="20%"><span class=""></span>全宗名称：</th>
						<td class="input-readonly"><input type="text" validType="length[0,100]"
							style="" class="easyui-validatebox"
							data-options="required:true" title="全宗名称" id="odName"
							value="<%=map.get("ORG_NAME") %>" readonly="readonly" /></td>
					</sec:accesscontrollist>
				</tr>
				<tr>
					<sec:accesscontrollist hasPermission="3"
						domainObject="formdialog_CbbFondsServiceAdd_formCbbFondsService_fullsvrType">
						<th width="20%"><span class="remind">*</span>全文服务器类型：</th>
						<td width="30%" class="input-readonly"><select title="全文服务器类型" editable="false"
							data-options="required:true,panelHeight:'auto',editable:false,onShowPanel:comboboxOnShowPanel"
							class="easyui-combobox" name="fullsvrType" id="fullsvrType"
							style=";" readonly="readonly">
								<%
									Collection<SysLookupSimpleVo> cbbFullsvrTypeList = (Collection<SysLookupSimpleVo>)request.getAttribute("cbbFullsvrTypeList");
									Iterator it = cbbFullsvrTypeList.iterator();
										while(it.hasNext()){
											SysLookupSimpleVo ss= (SysLookupSimpleVo)it.next();
											if(ss.getLookupCode().equals(map.get("FULLSVR_TYPE"))){
												%>
								<option value="<%=ss.getLookupCode() %>" selected="selected"><%=ss.getLookupName() %></option>
								<% 
											}
										}
									%>
						</select></td>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3"
						domainObject="formdialog_CbbFondsServiceAdd_formCbbFondsService_svrAddress">
						<th width="20%"><span class="remind">*</span>服务器地址：</th>
						<td><input type="text" validType="length[0,200]"
							style="" class="easyui-validatebox" title="服务器地址"
							id="svrAddress" name="svrAddress" data-options="required:true"
							value="<%= null == map.get("SVR_ADDRESS") ? "" : map.get("SVR_ADDRESS") %>" />
						</td>
					</sec:accesscontrollist>
				</tr>
				<tr>
					<sec:accesscontrollist hasPermission="3"
						domainObject="formdialog_CbbFondsServiceAdd_formCbbFondsService_svrPublishPath">
						<th width="20%"><span class="remind">*</span>发布路径：</th>
						<td width="30%"><input type="text" validType="length[0,200]"
							style="" class="easyui-validatebox" title="发布路径"
							id="svrPublishPath" name="svrPublishPath"
							data-options="required:true"
							value="<%= null == map.get("SVR_PUBLISH_PATH") ? "" : map.get("SVR_PUBLISH_PATH") %>" />
						</td>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3"
						domainObject="formdialog_CbbFondsServiceAdd_formCbbFondsService_ftpUser">
						<th width="20%"><span class="remind">*</span>FTP用户名：</th>
						<td><input type="text" validType="length[0,50]"
							style="" class="easyui-validatebox" title="FTP用户名"
							id="ftpUser" name="ftpUser"
							value="<%= null == map.get("FTP_USER") ? "" : map.get("FTP_USER") %>" />
						</td>
					</sec:accesscontrollist>
				</tr>
				<tr>
					<sec:accesscontrollist hasPermission="3"
						domainObject="formdialog_CbbFondsServiceAdd_formCbbFondsService_ftpPassword">
						<th width="20%"><span class="remind">*</span>FTP密码：</th>
						<td width="30%"><input type="password" validType="length[0,50]"
							style="" class="easyui-validatebox" title="FTP密码"
							id="ftpPassword" name="ftpPassword"
							value="<%= null == map.get("FTP_PASSWORD") ? "" : map.get("FTP_PASSWORD") %>" />
						</td>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3"
						domainObject="formdialog_CbbFondsServiceAdd_formCbbFondsService_isEncrypt">
						<th width="20%"><span class="remind">*</span>是否加密：</th>
						<td>
							<%	
							if(null != map.get("FULLSVR_TYPE") && !"1".equals(map.get("FULLSVR_TYPE")) && null != map.get("IS_ENCRYPT") && map.get("IS_ENCRYPT").equals("Y")){
									%>
							<span class="block-box">
								<input type="radio" class="radiobox" title="是否加密"
								id="isEncrypt1" name="isEncrypt" value="Y" checked="checked" />
								<span class="radiobox-text">是</span>
							</span>
							<span class="block-box">
								<input type="radio" class="radiobox" title="是否加密" 
								id="isEncrypt2" name="isEncrypt" value="N" />
								<span class="radiobox-text">否</span>
							</span>
							 <% 
								}else{
									%>
							<span class="block-box">
								<input type="radio" class="radiobox" title="是否加密"
								id="isEncrypt1" name="isEncrypt" value="Y"/>
								<span class="radiobox-text">是</span>
							</span>
							<span class="block-box">
								<input type="radio" class="radiobox" title="是否加密" 
								id="isEncrypt2" name="isEncrypt" value="N" checked="checked" />
								<span class="radiobox-text">否</span>
							</span>
							<% 
								}
							%>

						</td>
					</sec:accesscontrollist>
				</tr>
				<tr>
					<sec:accesscontrollist hasPermission="3"
						domainObject="formdialog_CbbFondsServiceAdd_formCbbFondsService_remark">
						<th width="20%"><span class=""></span>备注：</th>
						<td colspan="3"><textarea style=""
								type="text" class="textareabox" title='备注' name="remark"
								id="remark" validType="length[0,4000]"><%= null == map.get("REMARK") ? "" : map.get("REMARK") %></textarea>
						</td>
					</sec:accesscontrollist>
				</tr>
			</table>
			<div style="display: none;">
				<label>id</label>
				<div class="inputContainer">
					<input name="id" id="id" required="true"
						value="<%=map.get("ID") %>" style=";" />
				</div>
			</div>

			<div style="display: none;">
				<label>version</label>
				<div class="inputContainer">
					<input name="version" id="version" required="true"
						value="<%=map.get("VERSION") %>" style=";" />
				</div>
			</div>
		</form>
	</div>

	<div data-options="region:'south',border:false" style="height:40px;">
		<div id="toolbar" class="datagrid-toolbar datagrid-toolbar-extend foot-formopera">
			<table class="tableForm" border="0" cellspacing="1" width="100%">
				<tr>
					<td align="right">
						<sec:accesscontrollist hasPermission="3"
							domainObject="formdialog_CbbFondsServiceAdd_button_saveButton">
							<a id="saveButton" class="easyui-linkbutton primary-btn" onclick="saveForm();"
								href="javascript:void(0);">保存</a>
						</sec:accesscontrollist>
						<sec:accesscontrollist hasPermission="3"
							domainObject="formdialog_CbbFondsServiceAdd_button_resetForm">
							<a id="resetButton" class="easyui-linkbutton" 
								onclick="resetForm();" href="javascript:void(0);">重置</a>
						</sec:accesscontrollist>
						<sec:accesscontrollist hasPermission="3"
							domainObject="formdialog_CbbFondsServiceAdd_button_backForm">
							<a id="backButton" class="easyui-linkbutton" 
								onclick="closeWindow();" href="javascript:void(0);">返回</a>
						</sec:accesscontrollist>
				</td>
				</tr>
			</table>
		</div>
	</div>

	<script type="text/javascript">
		var dialogId = "${dialogId}";

		$(function() {

			if ($("#fullsvrType").val() == "1") {
				document.getElementById("isEncrypt1").disabled = "disabled";
				document.getElementById("isEncrypt2").disabled = "disabled";
				$("#ftpUser").attr("disabled", false);
				$("#ftpPassword").attr("disabled", false);
			} else {
				document.getElementById("isEncrypt1").disabled = "";
				document.getElementById("isEncrypt2").disabled = "";
				$("#ftpUser").val("");
				$("#ftpUser").attr("disabled", true);
				$("#ftpPassword").val("");
				$("#ftpPassword").attr("disabled", true);
			}
		});
		
		/**
		 * 获取字符串长度（汉字算两个字符，字母数字算一个）
		 * 
		 * @param str
		 * @returns {Number}
		 */
		function getByteLen(val) {
			var len = 0;
			for ( var i = 0; i < val.length; i++) {
				var a = val.charAt(i);
				if (a.match(/[^\x00-\xff]/ig) != null) {
					len += 2;
				} else {
					len += 1;
				}
			}
			return len;
		}

		//保存
		function saveForm() {
			/***必填字段空格验证 - 2015/11/17 增加 （郭亮）***/
			var svrAddress = $("#svrAddress").val().replace(/(^\s+)|(\s+$)/g,
					"");
			var svrPublishPath = $("#svrPublishPath").val().replace(
					/(^\s+)|(\s+$)/g, "");
			var ftpUser = $("#ftpUser").val().replace(/(^\s+)|(\s+$)/g, "");
			var ftpPassword = $("#ftpPassword").val();
			$("#svrAddress").val(svrAddress);
			$("#svrPublishPath").val(svrPublishPath);
			var fullsvrType = $("#fullsvrType").combobox("getText");
			if (fullsvrType == "FTP") {
				if (ftpUser == "") {
					$("#ftpUser").val("");
					$.messager.alert('提示', 'FTP用户名不能为空！', 'warning');
					return;
				}
				if (ftpPassword == "") {
					$.messager.alert('提示', 'FTP密码不能为空！', 'warning');
					return;
				}
			}
			// 备注长度检验   add by gl 2016-04-28
			var remark = $("#remark").val();
			var remarkLength = getByteLen(remark);
			if (remarkLength > 4000) {
				$.messager.alert('提示', '备注长度不能超过4000位！', 'warning');
				return;
			}
			/***必填字段空格验证 - 2015/11/17 增加 （郭亮）***/

			var validateFlag = $('#formCbbFondsService').form('validate');
			if (validateFlag == false) {
				return;
			}
			var dataVo = $('#formCbbFondsService').serializeArray();
			var dataJson = convertToJson(dataVo);
			dataVo = JSON.stringify(dataJson);
			$
					.ajax({
						url : 'platform/cbbFondsDbController/editUniqueValidate',
						data : {
							id : dataJson.id,
							fullsvrType : dataJson.fullsvrType,
							svrAddress : dataJson.svrAddress,
							svrPublishPath : dataJson.svrPublishPath,
							ftpUser : dataJson.ftpUser
						},
						type : 'post',
						dataType : 'json',
						success : function(result) {
							if (result.validate == "1") {
								$.messager.alert('提示', '已存在重复数据！', 'warning');
							} else {
								$
										.ajax({
											url : 'platform/cbbFondsDbController/saveCbbFondsServer',
											data : {
												datas : dataVo,
												type : 'edit'
											},
											type : 'post',
											dataType : 'json',
											success : function(result) {
												parent.freDataGrid();
												closeWindow();
											}
										});
							}
						}
					});
		}

		/**
		 * 关闭弹出窗口
		 */
		function closeWindow() {
			if (parent != null && parent.$('#' + dialogId) != null) {
				parent.$('#' + dialogId).dialog('close');
			}
		}

		/**
		 * 重置表单数据
		 */
		function resetForm(formName, type) {
			$('#formCbbFondsService').form('reset');
		}
		window.onresize = comboboxHidePanel;
	</script>
</body>
</html>